#include<stdio.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<stdlib.h>
int main()
{
    pid_t id = fork();
    if(id==0)
    {
        //child process
        int num=5;
        while(num!=0)
        {
            printf("I am child process,pid:%d,ppid:%d\n",getpid(),getppid());
            sleep(1);
            num--;
        }
        exit(1);
    }
    //father process
    int status=0;
    pid_t rid=wait(&status);
    if(rid>0)
    {
        printf("wait success status:%d\n",status);
    }
    else{
        printf("wait fail\n");
    }
    return 0;
}

